Index = {
	hideAll: function() {
		$("#mainView").hide();
		$("#gameView").hide();
		$("#listView").hide();
	},
	go: function(type, param) {
		layer.closeAll();
		if(type == "main") {
			$("#mainView").show();
			MainView.init(Game);
		} else if(type == "game") {
			$("#gameView").show();
			Game.changeUrl(BCConfig.url + "index.jsp" + "?hashId=" + param.hashId + "&eth=" + param.eth);
			GameView.init(Game, param);
		} else {
			$("#listView").show();
		}
	},
	changeUrl: function(url) {
		var stateObject = {};
		var title = "终端分歧机";

		history.pushState(stateObject, title, url);
	},
	init: function() {}
};

$(function() {
	App.init();
	App.canUse().then(function(b) {
		if(b) {
			BC_WS.init();
			MainView.init(Index);
		} else {
			var option = {
				title: "错误",
				msg: "ETH账号不能使用",
				actions: [{
					type: 'btn',
					title: "刷新",
					func: function(index) {
						BC_Notify.close();
						history.go(0);
					}
				}]
			};
			BC_Notify.show(option);
		}
	});

});